package net.lee.algorithm.linkedorder;

public class SingleLinkOrder {

    public static void main(String args[])
    {
        SingleLinkObject object1 = new SingleLinkObject();
        object1.setValue(1);

        SingleLinkObject object2 = new SingleLinkObject();
        object2.setValue(2);

        SingleLinkObject object3 = new SingleLinkObject();
        object3.setValue(3);

        object1.setNextSingleLinkObject(object2);

        object2.setNextSingleLinkObject(object3);

        SingleLinkObject linkObject =object1;

        SingleLinkObject tempObject  = new SingleLinkObject();
        while (linkObject !=null)
        {

            SingleLinkObject switchLinkObject = linkObject.getNextSingleLinkObject();

            linkObject.setNextSingleLinkObject(tempObject);


            tempObject = linkObject;
            if(switchLinkObject!=null)
            {
                linkObject = switchLinkObject;
            }
            else{

                break;
            }
        }


        while (linkObject!=null)
        {
            System.out.print(linkObject.getValue()+"-");
            linkObject =linkObject.getNextSingleLinkObject();
        }


    }
}
